package com.xuecheng.content.feignclient.media;

import com.xuecheng.media.model.po.MediaFiles;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@Component
public class MediaFileClientFactory implements FallbackFactory<MediaFileClient> {
    @Override
    public MediaFileClient create(Throwable throwable) {
        return new MediaFileClient() {
            @Override
            public MediaFiles getById(Long id) {
                log.error("调用媒资服务查询媒资文件发生熔断：{}",throwable.toString(),throwable);
                return null;
            }

            @Override
            public MediaFiles upload(MultipartFile filedata, String objectName) {
                log.error("调用媒资服务上传媒资文件发生熔断：{}",throwable.toString(),throwable);
                return null;
            }
        };
    }
}
